﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DBBase;
using System.Runtime.InteropServices;
using System.Xml;
using System.IO;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
using System.Threading;
using System.Web;
using System.Security;
using System.Security.Cryptography;
using FastReport;

namespace Business.报告单
{

    public class 新车
    {
        public void bgd(string lsh, string Url, string zt)
        {
            Report frt = new Report();
            frt.Load(Url);
            frt.RegisterData(GetData(lsh), "new");
            frt.GetDataSource("new").Enabled = true;
            if (zt == "1")
            {
                frt.Prepare();
                frt.PrintSettings.ShowDialog = false;
                frt.Print();
            }
            else if (zt == "2")
            {
                frt.Show();
            }
            else
            {
                frt.Design();
            }

        }

        private DataTable GetData(string lsh)
        {
            StringBuilder sql = new StringBuilder();
            sql.Append("SELECT AUTO.*,Detects_SJA.*,Detects_SJB.* ");
            sql.Append(",Detects_SJC.DET_LB,Detects_SJC.DET_LAJL,Detects_SJC.DET_LBCS ");
            sql.Append("From AUTO,Detects_SJA,Detects_SJB,Detects_SJC Where ");
            sql.Append("AUTO.AT_ID=Detects_SJA.AT_ID ");
            sql.Append("and Detects_SJB.DETECT_ID=Detects_SJA.DETECT_ID ");
            sql.Append("and Detects_SJC.DETECT_ID=Detects_SJB.DETECT_ID ");
            sql.AppendFormat("and Detects_SJA.DETECT_ID='{0}'", lsh);
            Query mquery = new Query();
            DataTable dt = mquery.GetTable(sql.ToString());
            ////return mquery.GetTable(sql.ToString());
            //if(dt.Rows.Count<1)
            //{
            //    //DataRow dr = new DataRow();
                
            //    dt.Rows.Add("1");
            //}
            //sql = new StringBuilder();
            //sql.Append("SELECT * ");
            //sql.Append("From StationInfor ");
            //DataTable dtex = mquery.GetTable(sql.ToString());
            //dt.Columns.Add("jczmc");
            //dt.Rows[0]["jczmc"] = dtex.Rows[0]["SI_NAME"].ToString().Trim();
            return dt;
        }

    }
}
